<style>
    #tag_ids2  span.tips {
        top: 0 !important;
    }
</style>
<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">

    <div class="layui-card-body">

        <div class="layui-form-item">
            <label class="layui-form-label">系统组织</label>
            <div class="layui-input-block">
                <select lay-search name="department_id" required>
                    <option value="">请选择系统组织</option>
                    {foreach $departmentList as $k => $v}
                    <option value="{$v.id}" {if isset($vo.department_id) and $vo.department_id eq $v.id} selected {/if}>{$v.spl}{$v.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">门店</label>
            <div class="layui-input-block" id="tag_ids2">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-block">
                <input name="name" required placeholder="请输入姓名" value="{$vo.name|default=''}" class="layui-input">
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">手机号码</label>
            <div class="layui-input-block">
                <input name="phone" required placeholder="请输入手机号码" value="{$vo.phone|default=''}" class="layui-input">
                <p class="help-block"></p>
            </div>
        </div>
    </div>
    <input id="distributor" type="text" value="{$distributor}" style="display: none">
    <input id="shop_id_check" type="text" value="{$vo.shop_id|default=''}" style="display: none">
    <div class="hr-line-dashed"></div>
    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}

    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>
</form>
<script>
    form.render();

    layui.config({
        base: '__ROOT__/static/plugs/layui/bin/selectMany/',
    }).extend({
        selectM: 'selectM',
    }).use(['selectM'], function () {
        var selectM = layui.selectM;
        var tagData = JSON.parse($('#distributor').val());
        var checkShopArr = ($('#shop_id_check').val()).split(',');;

        //多选标签-所有配置
        var tagIns2 = selectM({
            //元素容器【必填】
            elem: '#tag_ids2'
            //候选数据【必填】
            , data: tagData
            //默认值
            , selected: checkShopArr
        //最多选中个数，默认5
        , max: 50
                //input的name 不设置与选择器相同(去#.)
                , name: 'shop_id'
                //值的分隔符
                , delimiter: ','
                //候选项数据的键名
                , field: {idName: 'id', titleName: 'name'}
        });
    });
</script>

